<template>
    <div class="poa">
        <top @leftfn="back" :left="'el-icon-arrow-left'" :title="'修改资料'" />
        <div class="gun">
            <list :src="obj.userpic ? obj.userpic : 'http://43.138.15.137:8085/static/default.jpg'" :text="'头像'"
                :icon="'el-icon-edit'" />
            <list :right_text="form.username" :text="'昵称'" :icon="'el-icon-edit'" />
            <list @fn="set_sex" :right_text="form.sex" :text="'性别'" :icon="'el-icon-edit'" />
            <list :right_text="form.birthday" :text="'生日'" :icon="'el-icon-edit'" />
            <list :right_text="form.qg" :text="'情感'" :icon="'el-icon-edit'" />
            <list :right_text="form.job" :text="'职业'" :icon="'el-icon-edit'" />
            <list :right_text="form.path" :text="'家乡'" :icon="'el-icon-edit'" />
            <select_ :flag.sync="sex_flag" />
            <div class="bt"></div>
        </div>
    </div>
</template> 
<script>
import form_input from './common/form_input.vue';
import select_ from './common/select_.vue';
import submit from './common/submit.vue';
import top from './common/top.vue';
import list from './common/list.vue';
export default ({
    components: {
        top,
        submit,
        form_input,
        list,
        select_,
    },
    data() {
        return {
            obj: {

            },
            form: {
                username: '',
                sex: '',
                qg: '',
                birthday: '',
                job: '',
                userpic: '',
            },
            sex_flag: false,
        }
    },
    methods: {
        set_sex() {
            this.sex_flag = true
        },
        submit_login() {

        },
        back() {
            this.$router.go(-1)
        },
    },
    created() {
        this.obj = JSON.parse(localStorage.getItem('token'))
        let obj = JSON.parse(localStorage.getItem('token'))
        if (obj.userinfo.sex) {
            this.form.sex = obj.userinfo == 1 ? '男' : '女';
        } else {
            this.form.sex = '保密'
        }
        if (obj.userinfo.qg) {
            this.form.qg = obj.userinfo == 1 ? '未婚' : '已婚';
        } else {
            this.form.qg = '保密'
        }
        this.form.username = obj.username;
        this.form.birthday = obj.birthday || '';
        this.form.userpic = obj.userpic || '';
        this.form.job = obj.userinfo.job || '';
        console.log(this.form);
    }
})
</script>
<style scoped lang="scss">
@function r($v) {
    @return $v / (390 /10rem)
}
</style>